<template>
  <div class="content">
    <div class="header">
      <div class="header_top">
        <div class="showJifen">
          <img src="/img/jifen/dajifen.png" alt="">
          <span>{{pointsData.a}}</span>
        </div>
        <div class="availableJifen">
          可用积分
        </div>
      </div>
      <div class="header_bottom">
        <div class="bottom_l">
          <div class="number">{{pointsData.a}}</div>
          <div class="text">累计积分</div>
        </div>
        <div class="bottom_m"></div>
        <div class="bottom_l">
          <div class="number">0</div>
          <div class="text">使用积分</div>
        </div>
      </div>
    </div>
    <div class="middle">
      <div class="middle_l" @click="toPointsRules">
        <img src="/img/jifen/jifenguize.png" alt="">
        <span>积分规则</span>
      </div>
      <div class="middle_l" @click="toPointsDetails">
        <img src="/img/jifen/jifenmingxi.png" alt="">
        <span>积分明细</span>
      </div>
    </div>
    <div class="body">
      <div class="list">
        <div class="listHeader">
          <div class="line">
            <span>最近积分</span>
          </div>

        </div>
        <div class="listCon" v-for="(item, index) in pointsData.icrobotUserPoints" :key="index">
          <div class="con_l">
            <img src="/img/jifen/jifentubiao.png" alt="">
          </div>
          <div class="con_r">
            <div class="con_l_info">
              <div class="title">{{item.remark}}</div>
              <div class="date">{{item.createTime}}</div>
            </div>
            <div class="number">
              +<span>{{item.point}}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      pointsData: {}
    };
  },
  mounted() {
    this.queryMyPoint();
  },
  methods: {
    queryMyPoint() {
      (
        async () => {
          const {data} = await this.get("/user/queryMyPoint",{
            userId: localStorage.getItem("id")
          });
          this.pointsData = data;
        }
      )()
    },
    toPointsRules() {
      this.$router.push("/pointsRules");
    },
    toPointsDetails() {
      this.$router.push({
        path: "/pointsDetails",
        query: {
          data: this.pointsData
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.content {
  font-size: 0.1rem;
  width: 100%;
  min-height: 100%;
  background-color: #f7f9fa;
  .header {
    width: 7.5rem;
    height: 2.94rem;
    background-image: url("/img/jifen/banner.png");
    background-size: 100% 100%;
    .header_top {
      text-align: center;
      padding-top: 0.62rem;
      .showJifen {
        img {
          width: 0.37rem;
          height: 0.35rem;
        }
        span {
          display: inline-block;
          font-size: 0.7rem;
          height: 0.7rem;
          line-height: 0.7rem;
          font-family: PingFang SC;
          font-weight: bold;
          color: #ffffff;
          margin-left: 0.12rem;
        }
      }
      .availableJifen {
        font-size: 0.24rem;
        line-height: 0.24rem;
        font-family: PingFang SC;
        font-weight: bold;
        color: #ffffff;
        margin-top: 0.20rem;
      }
    }
    .header_bottom {
      display: flex;
      justify-content: center;
      justify-items: center;
      align-items: center;
      margin-top: 0.34rem;
      .bottom_l {
        text-align: center;
        .number {
          font-size: 0.28rem;
          line-height: 0.28rem;
          font-family: PingFang SC;
          font-weight: bold;
          color: #ffffff;
        }
        .text {
          font-size: 0.22rem;
          line-height: 0.22rem;
          font-family: PingFang SC;
          font-weight: bold;
          color: #ffffff;
          margin-top: 0.14rem;
        }
      }
      .bottom_m {
        width: 0.02rem;
        height: 0.5rem;
        background: #ffffff;
        margin: 0 1.41rem;
      }
    }
  }
  .middle {
    display: flex;
    .middle_l {
      width: 3.75rem;
      height: 0.78rem;
      background-color: #fff;
      display: flex;
      align-items: center;
      justify-content: center;
      img {
        width: 0.34rem;
        height: 0.33rem;
      }
      span {
        font-size: 0.28rem;
        font-family: PingFang SC;
        font-weight: bold;
        color: #333333;
        margin-left: 0.1rem;
      }
    }
  }
  .body {
    .list {
      .listHeader {
        width: 100%;
        height: 0.54rem;
        padding-top: 0.4rem;
        box-sizing: border-box;
        .line {
          width: 2.64rem;
          height: 0.04rem;
          background: #e7e7e7;
          margin: 0 auto;
          position: relative;
          span {
            width: 1.6rem;
            // height: 0.24rem;
            background-color: #f7f9fa;
            font-size: 0.24rem;
            font-family: PingFang SC;
            font-weight: bold;
            color: #9b9b9b;
            text-align: center;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
          }
        }
      }
      .listCon {
        padding: 0 0.24rem;
        margin-top: 0.4rem;
        display: flex;
        align-items: center;
        .con_l {
          margin-right: 0.24rem;
          img {
            width: 0.74rem;
            height: 0.74rem;
          }
        }
        .con_r {
          width: 6.52rem;
          display: flex;
          align-items: center;
          justify-content: space-between;
          border-bottom: 0.01rem #E7E7E7 solid;
          padding-bottom: 0.3rem;
          .con_l_info {
            .title {
              font-size: 0.28rem;
              line-height: 0.28rem;
              font-family: PingFang SC;
              font-weight: 400;
              color: #333333;
            }
            .date {
              font-size: 0.2rem;
              line-height: 0.2rem;
              font-family: PingFang SC;
              font-weight: 400;
              color: #9b9b9b;
              margin-top: 0.2rem;
            }
          }
          .number {
            font-size: 0.34rem;
            font-family: PingFang SC;
            font-weight: bold;
            color: #f9732c;
          }
        }
      }
    }
  }
}
</style>